<%@ page contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="static/element/index.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title></title>
    <style>
        .fail .layui-layer-content {
            background-color: brown;
            color: #eee;
            width: 400px;
            height: 30px;
            text-align: center;
        }

        .succeed .layui-layer-content {
            background-color: #0061A8;
            color: #eee;
            width: 400px;
            height: 30px;
            text-align: center;
        }

        * {
            padding: 0;
            margin: 0;
        }

        html {
            overflow-y: hidden;
        }

        body, html {
            width: 100%;
            height: 100%;
        }

        body {
            display: flex;
            flex-flow: column;
        }

        .fheader {
            height: 1%;
            min-height: 43px;
        }

        .fsection {
            /*flex-grow: 1;*/
            display: flex;
            flex-flow: row;
            /*height: 99%;*/
            min-height: 0;
        }

        .fnav {
            width: 360px;
            padding: 1px;
        }

        .farticle {
            flex: 1;
            padding: 1px;
        }

        .el-table__body tr:hover > td {
            background-color: #DFDFDF !important;
            cursor: default
        }

    </style>
</head>
<body>
<div id="app">
    <div class="fheader" style="padding: 0;margin: 0 ">
        <nav class="breadcrumb" style="height: 100%; padding: 0;margin: 0 ">
            <span class="l" style="color: #0000cc; padding: 0; margin: 0">当前部门：</span>
            <div class="l">{{currZzmc}} --> {{currBmmc}}</div>
            <span class="r" style="padding-top: 2px">共计员工：[&nbsp;<strong>{{iiCount}}</strong> 人]</span>
            <a class="btn btn-primary radius r" style="line-height:1.6em; margin-left: 5px; margin-right: 5px; margin-top: 6px" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
            <div class="r" style="margin-left: 20px; padding-top: 1px;"> 查询内容：
                <el-autocomplete
                        class="inline-input"
                        v-model="state2"
                        :fetch-suggestions="querySearch"
                        placeholder="请输入内容"
                        :trigger-on-focus="false"
                        clearable
                        @select="handleSelect">
                </el-autocomplete>
                <button @click="fSearchKh()" class="btn btn-success radius" name=""><i class="Hui-iconfont">&#xe665;</i>按卡号查询</button>
            </div>
        </nav>
    </div>
    <div class="fsection">
        <div class="fnav">
            <el-table :data="tableTree" stripe border style="width: 100%" :height="tableHeight" empty-text="没有数据" :header-cell-style="tableHeaderCellStyle" :cell-style="tableCellStyle" @row-click="fClickRow" v-loading.fullscreen.lock="fullscreenLoading">
                <el-table-column prop="VALUE01" label="组织名称" width="190"></el-table-column>
                <el-table-column prop="VALUE02" label="部门名称" width="150"></el-table-column>
            </el-table>
        </div>
        <div class="farticle">
            <div class="cl pd-5 bg-1 bk-gray" style="margin-top: 3px">
                <span class="l">
                    <a class="btn btn-success radius l" style="line-height:1.6em;margin-left: 2px;" @click="fExportQuery()" title="导出excel表单">导出所有人员表单</a>
                    <span style="padding-top: 50px; margin-left: 5px;">当前组织 ：[{{currZzmc}}] </span>
                </span>
                <span class="r">
                    <span style="padding-top: 50px; margin-right: 10px;">总计账户余额 ：[{{allZhye}}] </span>
                </span>
            </div>
            <div style="height: 100%; width: 100%; overflow: scroll; float: left; overflow-x: hidden;">
                <el-table :data="tableData" stripe border style="width: 100%" :height="tableHeightL" empty-text="没有数据" :header-cell-style="tableHeaderCellStyleL" :cell-style="tableCellStyleL">
                    <el-table-column prop="VALUE01" label="姓名" width="90"></el-table-column>
                    <el-table-column prop="VALUE02" label="工号" width="110"></el-table-column>
                    <el-table-column prop="VALUE03" label="部门" width="110"></el-table-column>
                    <el-table-column prop="VALUE04" label="人员类别" width="90"></el-table-column>
                    <el-table-column prop="VALUE05" label="消费类别" width="110"></el-table-column>
                    <el-table-column prop="VALUE19" label="卡号" width="140"></el-table-column>
                    <el-table-column prop="VALUE18" label="账户余额" width="140"></el-table-column>
                    <el-table-column prop="VALUE08" label="电话号码" ></el-table-column>
                </el-table>
            </div>
        </div>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/Layui_30023/layui.all.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/layui_exts/excel.js"></script>
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="static/axios.min.js"></script>
<script type="text/javascript" src="./static/vue"></script>
<script src="static/element/index.js"></script>
<script type="text/javascript">
    let vm = new Vue({
        el: '#app',
        data: {
            state2: '',
            restaurants: [],
            cxfs: '',
            tableHeight: 0,
            tableHeightL: 0,
            currZzbh: '',
            currZzmc: '',
            currBmbh: '',
            currBmmc: '',
            currDqlx: '',  //--标识出当前是部门还是公司

            ii_page: 1,   //--上一页下一页的计数器
            ii_row: 20,   //--每页显示的记录数
            iiCount: 0,
            is_search: '',
            tableTree: [],      //--部门表
            tableData: [],      //--具体人员信息表
            tableRylb: [],      //--人员类别
            tableXflb: [],      //--消费类别
            lock: false,
            currXflb: '',
            fullscreenLoading: false,
            tableQuery: [],
            allZhye:''
        },
        methods: {

            fExportQuery() {
                this.fullscreenLoading = true
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "BP");
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        let {db1} = res.data
                        self.tableQuery = db1
                        self.fExport()
                    })
                    .catch(function (error) {
                        layer.msg('<span style="font-size:24px; line-height: 30px">网络异常错误!</span>', {time: 2000, skin: 'fail'});
                    }).finally(function () {
                    self.fullscreenLoading = false
                });
            },

            fExport() {
                const excel = layui.excel;
                let data = excel.filterExportData(this.tableQuery, [
                    'VALUE01',
                    'VALUE02',
                    'VALUE03',
                    'VALUE04',
                    'VALUE05',
                    'VALUE06',
                    'VALUE07',
                    'VALUE08',
                    'VALUE09',
                    'VALUE10',
                    'VALUE11',
                    'VALUE12'
                ]);

                //--为头部定义中文名称
                data.unshift({
                    VALUE01: '公司',
                    VALUE02: '部门',
                    VALUE03: '姓名',
                    VALUE04: '工号',
                    VALUE05: '卡号',
                    VALUE06: '移动电话',
                    VALUE07: '员工类型',
                    VALUE08: '补贴类型',
                    VALUE09: '性别',
                    VALUE10: '状态',
                    VALUE11: '账户余额',
                    VALUE12: '身份证号'
                });
                excel.exportExcel({
                    sheet1: data
                }, '人员基本信息表.xlsx', 'xlsx');
            },

            fClickRow(row, column, event) {
                this.currZzbh = row.VALUE04
                this.currZzmc = row.VALUE06
                this.currBmbh = row.VALUE04
                this.currBmmc = row.VALUE02
                this.currDqlx = row.VALUE03
                this.fGetinfoEmp()
            },

            tableHeaderCellStyle({row, column, rowIndex, columnIndex}) {
                let cellStyle1;
                let cellStyle2;

                cellStyle1 = "color: #fff;" +
                    "background:#4F4F4F;" +
                    "text-align:center;" +
                    "font-size:14px"

                cellStyle2 = "color: #eee;" +
                    "background:#4F4F4F;" +
                    "text-align:center;" +
                    "display:none;" +
                    "font-size:14px"

                if (columnIndex > 1) {
                    return cellStyle2;
                } else {
                    return cellStyle1
                }
            },

            tableCellStyle({row, column, rowIndex, columnIndex}) {
                let cellStyle1;
                let cellStyle2;

                cellStyle1 = "text-align:center;" +
                    "padding:3px;" +
                    "font-size:14px"
                cellStyle2 = "text-align:left;" +
                    "padding:3px;" +
                    "font-size:14px"

                if (columnIndex === 0) {
                    return cellStyle1;
                } else if (columnIndex === 1) {
                    return cellStyle2
                }
            },

            tableHeaderCellStyleL({row, column, rowIndex, columnIndex}) {
                let cellStyle1;

                cellStyle1 = "color: #fff;" +
                    "background:#4F4F4F;" +
                    "text-align:center;" +
                    "font-size:14px"

                return cellStyle1
            },

            tableCellStyleL({row, column, rowIndex, columnIndex}) {
                let cellStyle1;

                cellStyle1 = "text-align:center;" +
                    "padding:8px 1px 8px;" +
                    "font-size:14px"
                return cellStyle1;
            },

            fRefresh() {
                this.fGetinfo();
            },

            //--查询出左边的部门信息以及相关下拉数据
            fGetinfo() {
                let ls_opid = "${sessionOpid}";
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "ZO");
                params.append('VALUE01', ls_opid);

                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        //--db1左边表结构的树  db2人员分类
                        let {db1, db2, db3, db4, db6} = res.data
                        self.tableTree = db1
                        self.tableRylb = db2
                        self.tableXflb = db3
                        self.restaurants = JSON.parse(JSON.stringify(db4).replace(/VALUE01/g, "value")
                            .replace(/VALUE02/g, "address"));
                        self.allZhye = db6[0].VALUE01
                    })
                    .catch(function (error) {
                        layer.msg('<span style="font-size:26px; line-height: 30px">网络异常错误!</span>', {time: 1500, skin: 'fail'});
                    });
            },

            //--查询出左边的部门信息以及相关下拉数据
            fGetinfoEmp() {
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "ZN");
                params.append('VALUE01', this.currBmbh);
                this.fullscreenLoading = true
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        //--db1左边表结构的树  db2人员分类
                        let {db1, db2, db3} = res.data
                        self.tableData = db1
                        self.iiCount = db2[0].VALUE01.toString()
                        self.currXflb = db3[0].VALUE02.toString()
                    })
                    .catch(function (error) {
                        layer.msg('<span style="font-size:26px; line-height: 30px">网络异常错误!</span>', {time: 1500, skin: 'fail'});
                    }).finally(function () {
                    self.lock = false
                    self.fullscreenLoading = false
                });
            },

            querySearch(queryString, cb) {
                let restaurants = this.restaurants;
                let results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
                // 调用 callback 返回建议列表的数据
                cb(results);
            },

            createFilter(queryString) {
                return (restaurants) => {
                    return (restaurants.value.toLowerCase().indexOf(queryString.toLowerCase()) >= 0);
                };
            },

            //--输入框选择后的人员帐号
            handleSelect(item) {
                this.ryzh = item.address
                this.cxfs = 'ZH'
                this.fSearch1()
            },

            //--依据选择的人员查询出基本信息
            fSearch1() {
                let ls_opid = "${sessionOpid}";
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "ZS");
                params.append('VALUE01', this.ryzh);
                params.append('VALUE02', this.cxfs);
                params.append('VALUE03', ls_opid);
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        let {db1, db2} = res.data
                        if (db2[0].VALUE01 === 'ZZ01') {
                            layer.msg('<span style="font-size:24px; line-height: 30px">' + db2[0].VALUE02 + '</span>', {time: 2000, skin: 'fail'});
                        } else {
                            self.tableData = db1
                            self.currZzbh = db2[0].VALUE01
                            self.currZzmc = db2[0].VALUE02
                            self.currBmbh = db2[0].VALUE03
                            self.currBmmc = db2[0].VALUE04
                        }
                    })
                    .catch(function (error) {
                        layer.msg('<span style="font-size:26px; line-height: 30px">网络异常错误!</span>', {time: 1500, skin: 'fail'});
                    });
            },

            //--按照输入的卡号进行查询
            fSearchKh() {
                let self = this
                layer.prompt({
                    formType: 0,
                    value: '',
                    title: '请读卡',
                    maxlength: 15,
                    area: ['300px', '120px'] //自定义文本域宽高
                }, function (value, index, elem) {
                    if (isNaN(value)) {
                        layer.msg('<span style="font-size:26px; line-height: 30px">请读出数字卡号!</span>', {time: 1500, skin: 'fail'});
                        return;
                    }
                    self.ryzh = value
                    self.cxfs = 'KH'
                    self.fSearch1()
                    layer.close(index);
                }, function () {
                });
            },
        },
        mounted() {
            window.fGetinfoEmp = this.fGetinfoEmp;
        },
        created() {
            let windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
            this.tableHeight = windowHeight - 42;
            this.tableHeightL = windowHeight - 135;
            this.fGetinfo()
        }
    });
</script>

</body>
</html>
